package com.squapsource.project_euler;

import java.math.BigInteger;

public class Problem30 {


	public static void main(String[] args) {
		long sum = 0;
		for (BigInteger a = BigInteger.valueOf(2); a.compareTo(BigInteger.valueOf(1000000)) <= 0; a = a.add(BigInteger.ONE))
		{
			BigInteger b = BigInteger.ZERO;
			for (char cha : a.toString().toCharArray())
			{
				b = b.add(BigInteger.valueOf(Long.valueOf(String.valueOf(cha))).pow(5));
			}
			if (a.equals(b))
			{
				System.out.println(a);
				sum += a.longValue();
			}

		}
		System.out.println("Sum " + sum);

	}

}
